package com.itheima.mapper;


import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


@Mapper
public interface EmpMapper {
//    @Select("select count(*) from web01.emp e left join web01.dept d on d.id = e.dept_id")
//    public long count();
//    @Select("select e.* ,d.name from  web01.emp e left join  web01.dept d on e.dept_id = d.id where e.name like '%张%' and e.gender = #{gender} and e.entry_date between #{begin} and #{end} order by e.update_time desc  limit #{start},#{pageSize}")
//    public List<Emp> list(@Param("start") Integer start, @Param("pageSize") Integer pageSize, String name, Integer gender, LocalDate begin, LocalDate end);
//    @Select("select e.* ,d.name from  web01.emp e left join  web01.dept d on e.dept_id = d.id   order by e.update_time desc  ")
//    public List<Emp> list();
//List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);
    public List<Emp> list(EmpQueryParam empQueryParam);
    @Options(useGeneratedKeys = true,keyProperty = "id")
@Insert("insert into emp( username,  name, gender,\n" +
        "                phone, job, salary, image, entry_date, dept_id, create_time, update_time)\n" +
        "values(#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{ updateTime})")
    void insert(Emp emp);

    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void updateById(Emp emp);
    //统计员工人数
    @MapKey("pos")
    List<Map<String, Object>> countEmpJobData();
    @Select("select id, username ,name from emp where username = #{username} and password = #{password}")
    Emp selectByUsernameAndPassword(Emp emp);
    @MapKey("name")
    List<Map<String, Object>> countEmpGenderData();
}
